import { DataSource, DataSourceOptions } from 'typeorm';

const dbConfig: DataSourceOptions = {
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'root',
  password: 'root',
  database: 'appshop',
};

export const ormConfig: DataSourceOptions = {
  ...dbConfig,
  entities: [
    'dist/modules/**/entities/*.entity{.ts,js}', // 对应的实体类位置
  ],
};
const ormConfigCLI: DataSourceOptions = {
  ...dbConfig,
  entities: ['./src/modules/**/entities/*.entity{.js,.ts}'],
  migrations: ['./migrations/*{.js,.ts}'],
  subscribers: ['./subscribers/*{.js,.ts}'],
  logger: 'file',
  logging: true,
};
export default new DataSource(ormConfigCLI);
